//
//  WMCAlertView.m
//  witMorning
//
//  Created by 信晨汇 on 2018/2/1.
//  Copyright © 2018年 zt. All rights reserved.
//

#import "WMCAlertView.h"

@implementation WMCAlertView

-(instancetype)initWithFrame:(CGRect)frame{
    
    if (self = [super initWithFrame:frame]) {
        
        UILabel *titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 20, frame.size.width-20, 50)];
        titleLabel.text = @"退出登录将会取消自动登录，您确定要退出登录吗?";
        titleLabel.numberOfLines = 0;
        titleLabel.font = [UIFont systemFontOfSize:15];
        titleLabel.textColor = [UIColor grayColor];
        [self addSubview:titleLabel];
       
        
        
        CGFloat width = 80;
        CGFloat space = 25;
        UIButton *confirmBtn = [self buttonFrame:CGRectMake((frame.size.width - width*2-25)/2 , titleLabel.bottom + 20, width, 40) title:@"确定"];
        [confirmBtn addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:confirmBtn];
        
        UIButton *cancelBtn = [self buttonFrame:CGRectMake(confirmBtn.right+space , titleLabel.bottom + 20, width, 40) title:@"取消"];
        [cancelBtn addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:cancelBtn];
    
        
        
        
    }
    
    
    return self;
    
}


-(void)click:(UIButton *)button{

    if (self.logOutClick) {
        self.logOutClick(button.titleLabel.text);
    }
}



-(UIButton *)buttonFrame:(CGRect)frame title:(NSString *)title{
    
    UIButton *button = [[UIButton alloc]initWithFrame:frame];
    [button setTitle:title forState:UIControlStateNormal];
    button.titleLabel.font = [UIFont systemFontOfSize:14];
    button.backgroundColor = RGB(205, 207, 206, 1);
    button.layer.cornerRadius = 5;
    button.clipsToBounds = YES;
    return button;
    
    
    
}

@end
